package io.lvdaxian.mybatis06.datasource.unpooled;


import io.lvdaxian.mybatis06.datasource.DataSourceFactory;

import javax.sql.DataSource;
import java.util.Properties;

public class UnpooledDataSourceFactory implements DataSourceFactory {
  protected Properties properties;
  
  @Override
  public DataSource getDataSource() {
    UnpooledDataSource unpooledDataSource = new UnpooledDataSource();
    
    unpooledDataSource.setUrl(properties.getProperty("url"));
    unpooledDataSource.setPassword(properties.getProperty("password"));
    unpooledDataSource.setUsername(properties.getProperty("username"));
    unpooledDataSource.setDriver(properties.getProperty("driver"));
    
    return unpooledDataSource;
  }
  
  @Override
  public void setProperties(Properties props) {
    this.properties = props;
  }
}
